package cn.stylefeng.guns.modular.gridsystem.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.gridsystem.model.param.BizGatewayTypeParam;
import cn.stylefeng.guns.modular.gridsystem.service.BizGatewayTypeService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 网关类型 控制器
 *
 * @author: ssy
 * @date: 2021/12/04 10:18
 */
@RestController
public class BizGatewayTypeController {

    @Resource
    private BizGatewayTypeService bizGatewayTypeService;

    /**
     * 分页查询网关类型
     *
     * @author ssy
     * @date 2021/12/04 10:18
     */
    @GetMapping("/bizGatewayType/page")
    @BusinessLog(title = "网关类型_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(BizGatewayTypeParam bizGatewayTypeParam) {
        return new SuccessResponseData(bizGatewayTypeService.page(bizGatewayTypeParam));
    }

    /**
     * 获取全部网关类型
     *
     * @author ssy
     * @date 2021/12/04 10:18
     */
    @GetMapping("/bizGatewayType/list")
    @BusinessLog(title = "网关类型_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list() {
        return new SuccessResponseData(bizGatewayTypeService.list());
    }

    /**
     * 查看详情网关类型
     *
     * @author ssy
     * @date 2021/12/04 10:18
     */
    @GetMapping("/bizGatewayType/detail")
    @BusinessLog(title = "网关类型_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(BizGatewayTypeParam.detail.class) BizGatewayTypeParam bizGatewayTypeParam) {
        return new SuccessResponseData(bizGatewayTypeService.detail(bizGatewayTypeParam));
    }

    /**
     * 添加网关类型
     *
     * @author ssy
     * @date 2021/12/04 10:18
     */
    @PostMapping("/bizGatewayType/add")
    @BusinessLog(title = "网关类型_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(BizGatewayTypeParam.add.class) BizGatewayTypeParam bizGatewayTypeParam) {
        bizGatewayTypeService.countByModel(bizGatewayTypeParam);
        bizGatewayTypeService.add(bizGatewayTypeParam);
        return new SuccessResponseData();
    }

    /**
     * 删除网关类型
     *
     * @author ssy
     * @date 2021/12/04 10:18
     */
    @PostMapping("/bizGatewayType/delete")
    @BusinessLog(title = "网关类型_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(BizGatewayTypeParam.delete.class) BizGatewayTypeParam bizGatewayTypeParam) {
        bizGatewayTypeService.delete(bizGatewayTypeParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑网关类型
     *
     * @author ssy
     * @date 2021/12/04 10:18
     */
    @PostMapping("/bizGatewayType/edit")
    @BusinessLog(title = "网关类型_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(BizGatewayTypeParam.edit.class) BizGatewayTypeParam bizGatewayTypeParam) {
        bizGatewayTypeService.edit(bizGatewayTypeParam);
        return new SuccessResponseData();
    }


}
